//父组件重新渲染，连带的子组件重新渲染
import { Component } from "react";

class Children extends Component {
    shouldComponentUpdate(nextProps, nextState){
        if(this.props.name==nextProps.name) return false;
        return true;
    }
    render() {
        console.log(this.props);
        console.log('Children render.');
        return (<div>Children component:{this.props.name}</div>)
    }
}

export default class Parent extends Component {
    state = {
        count: 0
    }
    render() {
        console.log("Parent render");
        return (
            <div>
                <button onClick={() => { this.setState({ count: this.state.count + 1 }) }}>count</button>
                <Children></Children>
                count: {this.state.count}
            </div>
        )
    }
}